home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_361 / xcolor-lib / demo_sources / demo_ii.s < prev    next >
Text File  |  1992-05-06  |  6KB  |  205 lines

  1.  
  2. ;   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  3. ;   ­­                                                                ­­
  4. ;   ­­                   DEMO II - XColor library                     ­­
  5. ;   ­­                                                                ­­
  6. ;   ­­                                                                ­­
  7. ;   ­­                     by Roger Fischlin                          ­­
  8. ;   ­­                        Steigerwaldweg 6                        ­­
  9. ;   ­­                        6450 Hanau 7                            ­­
  10. ;   ­­                        West Germany                            ­­
  11. ;   ­­                                                                ­­
  12. ;   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  13. ;   ­­    To run this demo the xcolor library must be available !     ­­
  14. ;   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  15. ;   ­­    This demo shows how you can use the user interface in       ­­
  16. ;   ­­                         assembler !                            ­­
  17. ;   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  18.  
  19.  
  20. ; user interface :
  21. ;
  22. ; · change colours using the cursor keys (up/down)
  23. ; · exit by pressing ESC
  24. ; · copy by pressing c 
  25. ;
  26.  
  27.  
  28.     incdir    "fh1:include/"            ; path may be different
  29.     include    "exec/exec_lib.i"
  30.     include    "intuition/intuitionbase.i"
  31.     include    "intuition/intuition.i"
  32.     include    "intuition/intuition_lib.i"
  33.  
  34.  
  35.  
  36.     include    "fh1:Color/XColor.i"
  37.  
  38.  
  39.  
  40.  
  41.     include    "misc/easystart.i"        ; I love the Workbench !
  42.  
  43.  
  44.  
  45.     move.l    #XC_VERSION,d0        ; open library
  46.     lea.l    XColorName(pc),a1
  47.     CALLEXEC    OpenLibrary
  48.     tst.l    d0
  49.     beq    NoLibrary
  50.     move.l    d0,_XColorBase
  51.  
  52.     move.l    d0,a0        ; XColor has already opened
  53.     move.l    XCb_IntuitionBase(a0),a0    ; the Intuition-Library - so why should I
  54.     move.l    ib_ActiveScreen(a0),d0    ; it a second time ????                    
  55.  
  56.  
  57.     lea.l    Palette(pc),a0        ; put up ColorRequester structure
  58.     move.l    d0,CR_Screen(a0)    ; ^screen
  59.     move.b    #0,CR_TextColour(a0)    ; pens
  60.     move.b    #1,CR_BackColour(a0)
  61.     move.b    #2,CR_GBorderColour(a0)
  62.     move.b    #0,CR_GTextColour(a0)
  63.     move.w    #10,CR_LeftEdge(a0)    ; X,Y
  64.     move.w    #10,CR_TopEdge(a0)
  65.     move.l    #4,CR_DefaultEntries(a0)    ; default workbench palette
  66.     move.l    #DefaultPalette,CR_DefaultColourMap(a0)
  67.     move.l    #ScreenTitle,CR_ScreenTitle(a0)    ; screen title        
  68.     move.l    #WindowTitle,CR_DefaultWTitle(a0)    ; defalut window title        
  69.  
  70.     move.l    #OpenWindow,CR_JMPWindow(a0)    ; user interface
  71.     clr.l    CR_JMPDraw(a0)
  72.     move.l    #NewMode,CR_JMPMode(a0)
  73.     move.l    #NewMessage,CR_JMPMessage(a0)
  74.     clr.l    CR_Font(a0)        ; use default font (should be 8x8)
  75.     move.l    #FLAG_NORMAL!FLAG_HSV,CR_Flags(a0)    ; don't use hex, but use HSV instead of RGB
  76.  
  77.  
  78.     CALLXCOLOR    ColourRequester
  79.  
  80.     move.l    _XColorBase,a1        ; close library
  81.     CALLEXEC    CloseLibrary
  82. NoLibrary    moveq.l    #0,d0
  83.     rts
  84.  
  85. XColorName    XCOLORNAME
  86. _XColorBase    dc.l    0
  87.  
  88.  
  89. Palette    ds.b    CR_SIZEOF
  90.     even
  91. DefaultPalette    dc.w    $05a,$fff,$000,$f80
  92.     even
  93. ScreenTitle    dc.b    "DEMO - XCOLOR LIBRARY BY ROGER FISCHLIN",0
  94.     even
  95. WindowTitle    dc.b    "Palette                           ",0
  96.     even
  97.  
  98.     
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. ; user interface
  107. ; ­­­­­­­­­­­­­­    
  108.  
  109.  
  110. ;
  111. ; set RAWKEY, d0 contains pointer to NewWindow
  112. ;
  113.  
  114. OpenWindow    move.l    d0,a0        ; d0 = ^NewWindow
  115.     or.l    #RAWKEY,nw_IDCMPFlags(a0)    ; set RAWKEY
  116.     rts
  117.  
  118.  
  119.  
  120. ;
  121. ; The requester obtained a message it couldn't use
  122. ;
  123.  
  124. NewMessage    lea.l    Palette(pc),a5        ; ColourRequester structure
  125.     cmp.l    #RAWKEY,CR_imClass(a5)    ; Class of message
  126.     bne    .Nothing        ; check if right message class
  127.     move.w    CR_imCode(a5),d0    ; rawkey code of pressed key
  128.  
  129.     btst    #7,d0        ; key still pressed ?
  130.     beq    .Nothing    
  131.     and.w    #$7f,d0        ; clear key-released-flag
  132.     cmp.b    #$45,d0
  133.     beq    .EXIT
  134.     cmp.b    #$4c,d0        ; check key
  135.     beq    .DOWN
  136.     cmp.b    #$4d,d0
  137.     beq    .UP
  138.     cmp.b    #$33,d0
  139.     beq    .COPY
  140. .Nothing    move.l    #CR_NOTHING,d0        ; Do nothing !
  141.     rts
  142.  
  143. .EXIT    move.l    #CR_EXIT,d0        ; leave ColourRequester !
  144.     rts
  145.  
  146. .UP    move.l    CR_Screen(a5),a0    ; get screen pointer
  147.     CALLXCOLOR    ColourNumber        ; get mask (number-1)
  148.     subq.l    #1,d0        
  149.     sub.l    #1,CR_Colour(a5)    ; previous Colour
  150.     and.l    d0,CR_Colour(a5)    ; & mask
  151.     move.l    #CR_NEWCOLOUR,d0    ; current colour has been changed !
  152.     rts
  153.  
  154. .DOWN    move.l    CR_Screen(a5),a0    ; get screen pointer
  155.     CALLXCOLOR    ColourNumber        ; get mask (number-1)
  156.     subq.l    #1,d0        
  157.     add.l    #1,CR_Colour(a5)    ; next Colour
  158.     and.l    d0,CR_Colour(a5)    ; & mask
  159.     move.l    #CR_NEWCOLOUR,d0    ; current colour has been changed !
  160.     rts
  161.  
  162. .COPY    cmp.l    #1<<31+1,CR_Mode(a5)    ; undo mode ?
  163.     beq    .Undo
  164.     move.l    #.CopyText,CR_WindowTitle(a5)    ; set new window title
  165.     move.l    #1<<31+1,CR_Mode(a5)    ; set user mode (bit 31=1)
  166.     move.l    #CR_NEWMODE,d0        ; new mode / window title
  167.     rts
  168. .Undo    move.l    #0,CR_Mode(a5)        ; clear mode
  169.     move.l    CR_DefaultWTitle(a5),CR_WindowTitle(a5)    
  170.                 ; set default window title
  171.     move.l    #CR_NEWMODE,d0        ; new mode / window title
  172.     rts
  173.  
  174.  
  175. .CopyText    dc.b    "Copy Colour To :                              ",0
  176.     even
  177.  
  178.  
  179. NewMode    lea.l    Palette(pc),a5        ; ColourRequester structure
  180.     cmp.l    #1<<31+1,CR_Mode(a5)        ; ckeck if right mode !
  181.     bne    .Nothing
  182.     move.l    d0,d6        ; d0= selected colour
  183.     move.l    CR_Screen(a5),a0
  184.     lea.l    sc_ViewPort(a0),a0
  185.     move.l    CR_Colour(a5),d0        
  186.     CALLXCOLOR    ReadRGB4        ; get RGB of source (current colour)
  187.     cmp.l    #-1,d0        ; error ????????    
  188.     beq    .Nothing    
  189.     move.l    d0,d1
  190.     move.l    d6,d0
  191.     move.l    CR_Screen(a5),a0
  192.     lea.l    sc_ViewPort(a0),a0
  193.     CALLXCOLOR    WriteRGB4        ; write RGB 
  194.     move.l    _XColorBase,a6
  195.     move.l    XCb_IntuitionBase(a6),a6    ; get Intuition library base 
  196.     jsr    _LVORemakeDisplay(a6)    ; remake display
  197.     clr.l    CR_Mode(a5)        ; clear mode
  198.     move.l    CR_DefaultWTitle(a5),CR_WindowTitle(a5)    ; set window title
  199.     move.l    d6,CR_Colour(a5)    ; destimation as new colour
  200.     move.l    #CR_NEWCOLOUR,d0
  201.     rts
  202. .Nothing    move.l    #CR_NOTHING,d0        ; Do nothing !
  203.     rts
  204.  
  205.